/**
 * <p>Copyright (c) 2011 深圳市鹏途信息技术有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	东莞交通工程质量监督综合业务系统        </p>
 * <p>创建者   :	adolf 
 * 
 * <p>描   述  :   AccidentReport0.java for com.pengtu.entity.quality    </p>
 * 
 * <p>最后修改 : $: 2011-8-2-上午09:31:38 v 1.0.0	 adolf   $     </p>
 * 
*/

package com.pengtu.entity.quality;

import java.math.BigDecimal;
import java.util.Comparator;
import java.util.Date;
import java.util.Set;
import java.util.TreeSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Where;

import com.pengtu.entity.IdEntity;
import com.pengtu.entity.app.Attachment;

/**
 * 
 * AccidentReport0
 * 
 * 2011-8-2 上午09:31:38
 * 
 * @version 1.0.0
 * 
 */

@Entity
@Table(name="T_Q_ACCIDENT_REPORT")
public class AccidentReport extends IdEntity {
	
	/**
	 * serialVersionUID:TODO
	 *
	 * @since 1.0.0
	 */
	
	private static final long serialVersionUID = 1L;
	private String pid;                       //关联项目ID
	private String projname;                  //关联项目名称
	private String type;                      //事故类型 
	private Date happendate;                  //发生时间
	private String happenplace;               //发生地点
	private Integer deaths;                	  //死亡人数              
	private BigDecimal loss;               	  //损失
	private String content;                   //简要经过
	private String damage;                    //造成工程损坏情况
	private String reason;                    //原因初步判断
	private String measure;                   //事故采取的措施   
	private String reportorg;                 //事故报告单位
	private String contentfile;               //附件  
	private String dealcontent;             //处理措施
	private Date dealdate;                  //处理时间
	private String dealcontentfile;         //处置附件 
	private String isdeal;                  //是否处理
	private String remark;                  //备注
	private Set<Attachment> contentfileSet = new TreeSet<Attachment>(new Comparator<Attachment>() {
		@Override
		public int compare(Attachment attFirst, Attachment attSecond) {
			// TODO Auto-generated method stub
			return attFirst.getCreateDate().compareTo(attSecond.getCreateDate());
		}
	});
	
	private Set<Attachment> dealcontentfileSet = new TreeSet<Attachment>(new Comparator<Attachment>() {
		@Override
		public int compare(Attachment attFirst, Attachment attSecond) {
			// TODO Auto-generated method stub
			return attFirst.getCreateDate().compareTo(attSecond.getCreateDate());
		}
	});
		
	public AccidentReport() {
	}

	@Column(name="PID")
	public String getPid() {
		return this.pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}
	
	@Column(name="PROJNAME")
	public String getProjname() {
		return this.projname;
	}

	public void setProjname(String projname) {
		this.projname = projname;
	}
	
	@Column(name="TYPE")
	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}

	
	public Date getHappendate() {
		return this.happendate;
	}

	public void setHappendate(Date happendate) {
		this.happendate = happendate;
	}

	public String getHappenplace() {
		return this.happenplace;
	}

	public void setHappenplace(String happenplace) {
		this.happenplace = happenplace;
	}

	public Integer getDeaths() {
		return this.deaths;
	}

	public void setDeaths(Integer deaths) {
		this.deaths = deaths;
	}

	public BigDecimal getLoss() {
		return this.loss;
	}

	public void setLoss(BigDecimal loss) {
		this.loss = loss;
	}

	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getDamage() {
		return this.damage;
	}

	public void setDamage(String damage) {
		this.damage = damage;
	}

	public String getReason() {
		return this.reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public String getMeasure() {
		return this.measure;
	}

	public void setMeasure(String measure) {
		this.measure = measure;
	}

	public String getReportorg() {
		return this.reportorg;
	}

	public void setReportorg(String reportorg) {
		this.reportorg = reportorg;
	}

	public String getContentfile() {
		return this.contentfile;
	}

	public void setContentfile(String contentfile) {
		this.contentfile = contentfile;
	}

	public String getDealcontent() {
		return this.dealcontent;
	}

	public void setDealcontent(String dealcontent) {
		this.dealcontent = dealcontent;
	}

	public Date getDealdate() {
		return this.dealdate;
	}

	public void setDealdate(Date dealdate) {
		this.dealdate = dealdate;
	}

	public String getDealcontentfile() {
		return this.dealcontentfile;
	}

	public void setDealcontentfile(String dealcontentfile) {
		this.dealcontentfile = dealcontentfile;
	}

	public String getIsdeal() {
		return this.isdeal;
	}

	public void setIsdeal(String isdeal) {
		this.isdeal = isdeal;
	}

	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@JoinColumn(name = "TABLEID")
	@Where(clause="tableField = 'accidentReport_contentfile' and delFlag = '0'")
	public Set<Attachment> getContentfileSet() {
		return contentfileSet;
	}
	
	public void setContentfileSet(Set<Attachment> contentfileSet) {
		
		this.contentfileSet = contentfileSet;
	}
	
	@Transient
	public Attachment getContfile(){
		if(contentfileSet.iterator().hasNext())
		return contentfileSet.iterator().next();
		return new Attachment();
	}

	public void setContfile(Attachment contfile){
		contentfileSet.clear();
		contentfileSet.add(contfile);
	}

	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@JoinColumn(name = "TABLEID")
	@Where(clause=" tableField = 'accidentReport_dealcontentfile' and  delFlag = '0'")
	public Set<Attachment> getDealcontentfileSet() {
		return dealcontentfileSet;
	}

	public void setDealcontentfileSet(Set<Attachment> dealcontentfileSet) {
		this.dealcontentfileSet = dealcontentfileSet;
	}
	
	@Transient
	public Attachment getDealfile(){
		if(dealcontentfileSet.iterator().hasNext())
		return dealcontentfileSet.iterator().next();
		return new Attachment();
	}

	public void setDealfile(Attachment dealfile){
		dealcontentfileSet.clear();
		dealcontentfileSet.add(dealfile);
	}
	
	

}

